Learn R Programming

VeryLargeIntegers (version 0.1.8)

03. Roots: Integer roots for vli Objects

Description

Computation of integer roots and their remainders of vli (Very Large Integers) objects. Functions sqrt and rootk return respectively the integer square root and the integer k-th root of the given value. Functions sqrtrem and rootkrem return the corresponding remainder.

Usage

# S3 method for vli
sqrt(x)

sqrtrem(x)

# S3 method for default sqrtrem(x)

# S3 method for numeric sqrtrem(x)

# S3 method for vli sqrtrem(x)

rootk(x, k)

# S3 method for default rootk(x, k)

# S3 method for numeric rootk(x, k)

# S3 method for vli rootk(x, k)

rootkrem(x, k)

# S3 method for default rootkrem(x, k)

# S3 method for numeric rootkrem(x, k)

# S3 method for vli rootkrem(x, k)

Value

object of class vli

Arguments

x

base of the root; object of class vli or 32 bits integer

k

index of the root; object of class vli or 32 bits integer

Author

Javier Leiva Cuadrado

Examples

Run this code
if (FALSE) {
x <- as.vli("4124135")
sqrt(x)
sqrtrem(x)
sqrt(x)^2 + sqrtrem(x) == x
rootk(as.vli("1492346293864978561249785"), 5)
}

Run the code above in your browser using DataLab